package com.ccit.springbootlaw.pojo;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Objects;

@Entity
@Table(name = "subscriptions") // 显式指定表名
// 权益包表
// id (主键)
// type (权益包类型)
// created_at (创建时间)
// updated_at (更新时间)
// duration (持续时间)
public class Subscription {
    private int id;
    private String type;
    private Timestamp created_at;
    private Timestamp updated_at;
    private int duration;

    @Id
    @Column(name = "id")
    // id (主键)
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Basic
    @Column(name = "type")
    // type (权益包类型)
    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    @Basic
    @Column(name = "created_at")
    // created_at (创建时间)
    public Timestamp getCreatedAt() {
        return created_at;
    }

    public void setCreatedAt(Timestamp createdAt) {
        this.created_at = createdAt;
    }

    @Basic
    @Column(name = "updated_at")
    // updated_at (更新时间)
    public Timestamp getUpdatedAt() {
        return updated_at;
    }

    public void setUpdatedAt(Timestamp updatedAt) {
        this.updated_at = updatedAt;
    }

    @Basic
    @Column(name = "duration")
    // duration (持续时间)
    public int getDuration() {
        return duration;
    }

    public void setDuration(int duration) {
        this.duration = duration;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Subscription that = (Subscription) o;
        return id == that.id && duration == that.duration && Objects.equals(type, that.type) && Objects.equals(created_at, that.created_at) && Objects.equals(updated_at, that.updated_at);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, type, created_at, updated_at, duration);
    }
}